﻿using System;
using System.Configuration;

namespace ipFoo.Models
{
    public static class Settings
    {
        public static string ContactMail
        {
            get
            {
                // Grab our email address from web.config
                var email = ConfigurationManager.AppSettings["contact_email"];
                return email == "SET CONTACT EMAIL HERE" || string.IsNullOrWhiteSpace(email) ? Resources.ResponseStrings.EmailNotSet : string.Format("mailto:{0}", email);
            }
        }

        public static string AnalyticsKey
        {
            get
            {
                // Grab our google analytics key from web.config
                var analytics = ConfigurationManager.AppSettings["analytics_key"];
                return analytics == "SET GOOGLE ANALYTICS KEY HERE" || string.IsNullOrWhiteSpace(analytics) ? null : analytics;
            }

        }

        public static string RecaptchaPublicKey {
            get
            {
                // Grab our recaptcha public key from web.config. Throw error if invalid
                var publicKey = ConfigurationManager.AppSettings["recaptchakey_public"];
                if (string.IsNullOrEmpty(publicKey) || publicKey == "SET PUBLIC KEY HERE")
                    throw new Exception("Recaptcha public key is not set in web.config -- please do that first!");
                return publicKey;
            }
        }

        internal static string RecaptchaPrivateKey
        {
            get
            {
                // Grab the private key from web.config. Throw error if invalid
                var privateKey = ConfigurationManager.AppSettings["recaptchakey_private"];
                if (string.IsNullOrEmpty(privateKey) || privateKey == "SET PRIVATE KEY HERE")
                    throw new Exception("Recaptcha private key is not set in web.config -- please do that first!");
                return privateKey;
            }
        }
    }
}